package impl;


import anaydis.sort.SorterType;
import com.sun.istack.internal.NotNull;

import java.util.Comparator;
import java.util.List;

public class HSorter extends AbstractSorter {
    int h=10;

    public HSorter() {
        super(SorterType.H);

    }

    public HSorter(SorterType shell) {
        super(shell);
    }

    public void setH(int h) {
        this.h = h;
    }

    public <T> void sort(@NotNull Comparator<T> tComparator, @NotNull List<T> ts) {
        miniSort(tComparator, ts);
    }

    protected <T> void miniSort(Comparator<T> tComparator, List<T> ts) {

        for (int i = h; i < ts.size(); i = i + h) {
            if (h < ts.size() && greater(tComparator, ts, i - h, i)) {
                swap(ts, i - h, i);

            }
        }
    }
}
